//https://www.nowcoder.com/practice/a5c127769dd74a63ada7bff37d9c5815?tpId=295&tqId=2285837&ru=%2Fpractice%2Fc5fbf7325fbd4c0ea3d0c3ea6bc6cc79&qru=%2Fta%2Fformat-top101%2Fquestion-ranking&sourceUrl=%2Fexam%2Fcompany
//房子围成环状，即第一个房子与最后一个相邻

int rob_x(int* nums, int numsLen ) {
    // write code here
    int dp[numsLen + 3];
    int max = 0;
    memset(dp, 0, sizeof(dp));
    for(int i = 0; i < numsLen; i++)
    {
        dp[i + 3] = (dp[i] > dp[i + 1] ? dp[i] : dp[i + 1]) + nums[i];
        max = max > dp[i + 3] ? max : dp[i + 3];
    }
    return max;
}

int rob(int* nums, int numsLen ) {
    // write code here
    int amountb = rob_x(nums, numsLen - 1);
    int amounte = rob_x(nums + 1, numsLen - 1);
    return amountb > amounte ? amountb : amounte;
}